<template>
  <div>
    <!-- 搜索 -->
    <!-- 技术报告 - 现场处理人 -->
    <TopFilter :list="topFilterInit" :cols="3" :collapse="collapse" labelWidth="90" @filterChange="changeHandle"></TopFilter>
    <!-- table -->
    <FilterTable
      height="auto"
      selectionType="single"
      ref="table"
      :columns="columns"
      :params="fetchParams"
      :dataSource="dataList"
      :datakey="'records'"
      :fetchapi="fetchApi"
      :onColumnsChange="columns => (this.columns = columns)"
      :onRowSelectChange="selectChange"
    >
    </FilterTable>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <multiuse-button type="primary" :click="saveDialog.bind()">确 定</multiuse-button>
      <multiuse-button @click="closeDialog">关 闭</multiuse-button>
    </div>
  </div>
</template>
<script>
// import res from '@/mock/tableData';
import { getDealPersonList } from '@/api/dictionary/index';
import { searchRoleByCode } from '@/api/common/empSelect/index';
import { searchRoleByCodes } from '@/api/customerCare/visitAllocation/getVisitInfo';
import dictCode from '@/utils/dictCode';

export default {
  // mixins: [dictionary],
  data() {
    return {
      dataList: [],
      visible: false,
      visibleDrawer: false,
      collapse: false,
      infoId: null,
      topFilterInit: this.topFilterInitFun(),
      columns: this.creatHeader(),
      fetchApi: getDealPersonList,
      fetchParams: {}, //ipa 接口
      selectedRows: [] //选中经销商
    };
  },
  created() {},
  methods: {
    async getDcrcAdvisor() {
      let roleParm = {
        role: dictCode.CUSTOMER_SERVICE_SPECIALIST
      };
      const res = await searchRoleByCodes(roleParm);
      this.topFilterList.find(item => item.fieldName === 'stalker').itemList = this.formList.find(item => item.fieldName === 'tracerList').itemList = res.data.map(x => ({
        value: x.userId,
        text: x.employeeName
      }));
    },
    //选中
    selectChange(rows) {
      this.selectedRows = rows;
      console.log(this.selectedRows);
    },
    //保存
    saveDialog() {
      this.$emit('save', this.selectedRows);
    },
    //取消操作
    closeDialog() {
      this.$emit('close', { visible: false, data: this.selectedRows, type: 'close' });
    },
    chooseOrderNo() {
      this.visible = true;
    },
    //搜索获取数据
    changeHandle(val) {
      this.fetchParams = val;
      console.log(val);
    },
    //搜索数据
    topFilterInitFun() {
      return [
        { type: 'INPUT', label: '员工姓名', fieldName: 'siteDealer', placeholder: '请输入', initialValue: '' }
        // { type: 'INPUT', label: '经销商名称', fieldName: 'dealerName', placeholder: '请输入', initialValue: '' }
      ];
    },
    //table表头和数据源
    creatHeader() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        { title: '员工姓名', dataIndex: 'siteDealer', sorter: true },
        { title: '联系电话', dataIndex: 'sitePhone', sorter: true },
        { title: '邮箱', dataIndex: 'siteEmail', sorter: true }
      ];
    }
  }
  // mounted() {
  //   this.BaseTable = this.$refs.listModal.$refs.pageTable;
  // }
};
</script>

<style lang="less" scoped></style>
